/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Francisco
 */
@Entity
@Table(name = "ingreso")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ingreso.findAll", query = "SELECT i FROM Ingreso i"),
    @NamedQuery(name = "Ingreso.findByIdIngreso", query = "SELECT i FROM Ingreso i WHERE i.idIngreso = :idIngreso"),
    @NamedQuery(name = "Ingreso.findByNombre", query = "SELECT i FROM Ingreso i WHERE i.nombre = :nombre"),
    @NamedQuery(name = "Ingreso.findByDescripcion", query = "SELECT i FROM Ingreso i WHERE i.descripcion = :descripcion"),
    @NamedQuery(name = "Ingreso.findByCapital", query = "SELECT i FROM Ingreso i WHERE i.capital = :capital"),
    @NamedQuery(name = "Ingreso.findByRetencion", query = "SELECT i FROM Ingreso i WHERE i.retencion = :retencion"),
    @NamedQuery(name = "Ingreso.findByFechaCreacion", query = "SELECT i FROM Ingreso i WHERE i.fechaCreacion = :fechaCreacion"),
    @NamedQuery(name = "Ingreso.findByFechaUltimaAct", query = "SELECT i FROM Ingreso i WHERE i.fechaUltimaAct = :fechaUltimaAct"),
    @NamedQuery(name = "Ingreso.findByPeriodicidad", query = "SELECT i FROM Ingreso i WHERE i.periodicidad = :periodicidad"),
    @NamedQuery(name = "Ingreso.findByMonto", query = "SELECT i FROM Ingreso i WHERE i.monto = :monto"),
    @NamedQuery(name = "Ingreso.findByEstatus", query = "SELECT i FROM Ingreso i WHERE i.estatus = :estatus")})
public class Ingreso implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_ingreso")
    private Integer idIngreso;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "nombre")
    private String nombre;
    @Size(max = 200)
    @Column(name = "descripcion")
    private String descripcion;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "capital")
    private BigDecimal capital;
    @Basic(optional = false)
    @NotNull
    @Column(name = "retencion")
    private BigDecimal retencion;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fecha_creacion")
    @Temporal(TemporalType.DATE)
    private Date fechaCreacion;
    @Column(name = "fecha_ultima_act")
    @Temporal(TemporalType.DATE)
    private Date fechaUltimaAct;
    @Column(name = "periodicidad")
    private Integer periodicidad;
    @Column(name = "monto")
    private BigDecimal monto;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "estatus")
    private String estatus;
    @ManyToMany(mappedBy = "ingresoList")
    private List<Reporte> reporteList;
    @JoinTable(name = "ingreso_categoria", joinColumns = {
        @JoinColumn(name = "id_ingreso", referencedColumnName = "id_ingreso")}, inverseJoinColumns = {
        @JoinColumn(name = "id_categoria", referencedColumnName = "id_categoria")})
    @ManyToMany
    private List<Categoria> categoriaList;
    @JoinColumn(name = "id_consumidor", referencedColumnName = "id_consumidor")
    @ManyToOne(optional = false)
    private Consumidor idConsumidor;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idIngreso")
    private List<OperarConsumoIngreso> operarConsumoIngresoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idIngreso")
    private List<TransferenciaIngreso> transferenciaIngresoList;
    @OneToMany(mappedBy = "idIngresoOrigen")
    private List<OperarIngreso> operarIngresoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idIngresoDestino")
    private List<OperarIngreso> operarIngresoList1;

    public Ingreso() {
    }

    public Ingreso(Integer idIngreso) {
        this.idIngreso = idIngreso;
    }

    public Ingreso(Integer idIngreso, String nombre, BigDecimal capital, BigDecimal retencion, Date fechaCreacion, String estatus) {
        this.idIngreso = idIngreso;
        this.nombre = nombre;
        this.capital = capital;
        this.retencion = retencion;
        this.fechaCreacion = fechaCreacion;
        this.estatus = estatus;
    }

    public Integer getIdIngreso() {
        return idIngreso;
    }

    public void setIdIngreso(Integer idIngreso) {
        this.idIngreso = idIngreso;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public BigDecimal getCapital() {
        return capital;
    }

    public void setCapital(BigDecimal capital) {
        this.capital = capital;
    }

    public BigDecimal getRetencion() {
        return retencion;
    }

    public void setRetencion(BigDecimal retencion) {
        this.retencion = retencion;
    }

    public Date getFechaCreacion() {
        return fechaCreacion;
    }

    public void setFechaCreacion(Date fechaCreacion) {
        this.fechaCreacion = fechaCreacion;
    }

    public Date getFechaUltimaAct() {
        return fechaUltimaAct;
    }

    public void setFechaUltimaAct(Date fechaUltimaAct) {
        this.fechaUltimaAct = fechaUltimaAct;
    }

    public Integer getPeriodicidad() {
        return periodicidad;
    }

    public void setPeriodicidad(Integer periodicidad) {
        this.periodicidad = periodicidad;
    }

    public BigDecimal getMonto() {
        return monto;
    }

    public void setMonto(BigDecimal monto) {
        this.monto = monto;
    }

    public String getEstatus() {
        return estatus;
    }

    public void setEstatus(String estatus) {
        this.estatus = estatus;
    }

    @XmlTransient
    public List<Reporte> getReporteList() {
        return reporteList;
    }

    public void setReporteList(List<Reporte> reporteList) {
        this.reporteList = reporteList;
    }

    @XmlTransient
    public List<Categoria> getCategoriaList() {
        return categoriaList;
    }

    public void setCategoriaList(List<Categoria> categoriaList) {
        this.categoriaList = categoriaList;
    }

    public Consumidor getIdConsumidor() {
        return idConsumidor;
    }

    public void setIdConsumidor(Consumidor idConsumidor) {
        this.idConsumidor = idConsumidor;
    }

    @XmlTransient
    public List<OperarConsumoIngreso> getOperarConsumoIngresoList() {
        return operarConsumoIngresoList;
    }

    public void setOperarConsumoIngresoList(List<OperarConsumoIngreso> operarConsumoIngresoList) {
        this.operarConsumoIngresoList = operarConsumoIngresoList;
    }

    @XmlTransient
    public List<TransferenciaIngreso> getTransferenciaIngresoList() {
        return transferenciaIngresoList;
    }

    public void setTransferenciaIngresoList(List<TransferenciaIngreso> transferenciaIngresoList) {
        this.transferenciaIngresoList = transferenciaIngresoList;
    }

    @XmlTransient
    public List<OperarIngreso> getOperarIngresoList() {
        return operarIngresoList;
    }

    public void setOperarIngresoList(List<OperarIngreso> operarIngresoList) {
        this.operarIngresoList = operarIngresoList;
    }

    @XmlTransient
    public List<OperarIngreso> getOperarIngresoList1() {
        return operarIngresoList1;
    }

    public void setOperarIngresoList1(List<OperarIngreso> operarIngresoList1) {
        this.operarIngresoList1 = operarIngresoList1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idIngreso != null ? idIngreso.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ingreso)) {
            return false;
        }
        Ingreso other = (Ingreso) object;
        if ((this.idIngreso == null && other.idIngreso != null) || (this.idIngreso != null && !this.idIngreso.equals(other.idIngreso))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Ingreso[ idIngreso=" + idIngreso + " ]";
    }
    
}
